import * as echart from "echarts";
const echartInit = () => {
  const mychart = echart.init(document.getElementById("echarts1"));
  // console.log(document.getElementById("echarts1"));
  const option = {
    // backgroundColor: "white",
    tooltip: {
      show: true,
      trigger: "item",
      //{a}(系列名)，{b}(数据项名),{c}(数值),{d}(百分比)
      formatter: "{a} <br/>{b} : {c}",
      backgroundColor: "rgba(1, 13, 19, 0.5)",
      borderWidth: 0,
      textStyle: {
        color: "rgba(212, 232, 254, 1)",
        // fontSize: fontChart(0.24),
      },
    },

    legend: {
      orient: "vertical",
      top: 20,
      left: 4,
      itemWidth: 10,
      itemHeight: 10,
      itemGap: 25,
      borderRadius: 4,
      textStyle: {
        color: "#fff",
        fontFamily: "Alibaba PuHuiTi",
        fontSize: 14,
        fontWeight: 400,
      },
    },
    series: [
      {
        zoom: 2,
        name: "",
        type: "pie",
        left: 7,
        // radius: "50%",
        top: 60,
        center: ["59%", "40%"],
        data: [
          { value: 1048, name: "电子商务" },
          { value: 735, name: "金融行业" },
          { value: 580, name: "旅游行业" },
          { value: 484, name: "医疗行业" },
          { value: 300, name: "汽车行业" },
        ],
        labelLine: {
          show: false,
        },
        width: "100%",
        height: "100%",
        label: {
          show: false,
          // normal: {
          //   // formatter: ["{b|{b}}", "{c|{c}}"].join("\n"),
          //   // rich: {
          //   //   c: {
          //   //     color: "inherit",
          //   //     fontSize: 20,
          //   //     fontWeight: "bold",
          //   //     lineHeight: 5,
          //   //   },
          //   //   b: {
          //   //     fontSize: 15,
          //   //     height: 40,
          //   //   },
          //   // },
          // },
        },
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: "rgba(0, 0, 0, 0.5)",
          },
        },
      },
    ],
  };
  mychart.setOption(option);
  window.addEventListener("resize", function () {
    mychart.resize();
  });
};

export default echartInit;
